<!DOCTYPE html>
<script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script>
<script>
async_test(t => {
  var offscreen = new OffscreenCanvas(50, 50);
  var ctx = offscreen.getContext('2d');
  ctx.fillStyle = '#0f0';
  ctx.fillRect(0, 0, 50, 50);
  createImageBitmap(offscreen).then(image => {
    var output = new OffscreenCanvas(50, 50);
    var outCtx = offscreen.getContext('2d');
    outCtx.drawImage(image, 0, 0);
    var pixel = outCtx.getImageData(0, 0, 1, 1).data;
    t.step(function() {
      assert_array_equals(pixel, [0, 255, 0, 255]);
    });
    t.done();
  });
}, "Call createImageBitmap on OffscreenCanvas with 2D context");
</script>
